package top.bingoz.wanandroid.presenter

import top.bingoz.wanandroid.base.BasePresenter
import top.bingoz.wanandroid.bean.Banner
import top.bingoz.wanandroid.contract.BannerContract
import top.bingoz.wanandroid.data.http.observer.SimpleSubscriber
import top.bingoz.wanandroid.data.http.transformer.DataTransformer
import top.bingoz.wanandroid.model.ApiModel
import javax.inject.Inject

/**
 * @author su
 * @date 2018/7/30
 * @description
 */
class BannerPresenter @Inject constructor(private var apiModel: ApiModel) : BasePresenter<BannerContract.View>(), BannerContract.Presenter {

    override fun getBanner() {
        apiModel.getBanner()
                .compose<List<Banner>>(DataTransformer(bindToLifecycle()))
                .subscribe(object : SimpleSubscriber<List<Banner>>() {

                    override fun onNext(data: List<Banner>) {
                        super.onNext(data)
                        mView?.showBanner(data)
                    }
                })


    }

}